package com.test.VT.CreateVT;

import com.test.VT.Thread.CustomThread;

import java.util.concurrent.ThreadFactory;

/**
 * 创建虚拟线程
 * @author caoqianfan
 * @date 2024/9/27 14:07
 */
public class By_ThreadFactory {
    public static void main(String[] args) {
        CustomThread customThread = new CustomThread();
        // 获取线程工厂类
        ThreadFactory factory = Thread.ofVirtual().factory();
        // 创建虚拟线程
        Thread thread = factory.newThread(customThread);
        // 启动线程
        thread.start();
    }
}
